/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import util.InternalMessageEntityListener;

/**
 *
 * @author wei
 */
@Entity(name="InternalMessageReceived")
public class InternalMessageReceivedEntity extends DataObjectEntity implements Serializable {

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date openedAt;
    
    @ManyToOne
    private SystemUserEntity receiver;
    
    @ManyToOne
    private InternalMessageEntity msg;

    public InternalMessageReceivedEntity() {
        super();
    }

    public InternalMessageEntity getMsg() {
        return msg;
    }

    public void setMsg(InternalMessageEntity msg) {
        this.msg = msg;
    }

    public Date getOpenedAt() {
        return openedAt;
    }

    public void setOpenedAt(Date openedAt) {
        this.openedAt = openedAt;
    }

    public SystemUserEntity getReceiver() {
        return receiver;
    }

    public void setReceiver(SystemUserEntity receiver) {
        this.receiver = receiver;
    }
    
    public boolean read(){
        return openedAt != null;
    }

    @Override
    public String childToString() {
        return "InternalMessageReceivedEntity{" + "openedAt=" + openedAt + ", receiver=" + receiver + ", msg=" + msg + '}';
    }
    
}
